<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
邮箱：<input type="text" id="mail"> <button onclick="fasong()">发送</button>
<br>
验证码：<input type="text" id="code">
<br>
<button onclick="zhuce()" >注册</button>
</body>

<script src="js/jquery-2.2.4.js"></script>
<script>

    function fasong() {
        $.ajax({
            url:"/sendMail",
            data:{mail:$("#mail").val()},
            success:function (res) {
                alert("发送成功");
            },
            error:function (res) {
                alert("网络错误");
            }
        })
    };
    function zhuce() {
        $.ajax({
            url:"/checkCode",
            data:{
                mail:$("#mail").val(),code:$("#code").val()
            },
            success:function (res) {
                alert(res)
                if (res==true){
                    alert("注册成功");
                }else{
                    alert("注册失败");
                }
            },
            error:function (res) {
                alert("网络错误");
            }

        })
    }

</script>
</html>